# -*- coding: utf-8 -*-    
from django.db.models import get_models, signals
from djbugz import models

def create_types(app, created_models, verbosity, **kwargs):
    if app != models:
        return
    
    if models.Priority.objects.all().count() != 3:
        models.Priority.objects.all().delete()    
        for order, name, is_default in [
            (+1, u'срочно', False),
            ( 0, u'нормальный', True),
            (-1, u'не горит', False),
        ]:
            models.Priority(order=order, name=name, is_default=is_default).save()

    if models.Category.objects.all().count() != 3:
        models.Category.objects.all().delete()    
        for order, name, is_default in [
            (1, u'задача', True),
            (2, u'баг', False),
            (3, u'фича', False),
        ]:
            models.Category(order=order, name=name, is_default=is_default).save()
    
    if models.Reason.objects.all().count() != 3:
        models.Reason.objects.all().delete()    
        for order, name, is_default in [
            (1, u'готово', True),
            (2, u'невозможно сделать', False),
            (3, u'больше не актуально', False),
        ]:
            models.Reason(order=order, name=name, is_default=is_default).save()
                        
    
signals.post_syncdb.connect(create_types)
